import React from 'react';
import {WeaSearchGroup, WeaFormItem, WeaBrowser, WeaCheckbox} from 'ecCom';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
import EType from './base/EType';
import ETitle from './base/ETitle';

// 文档内容
export default class Content_25 extends React.Component {
    state = {
        eDocContentFormIds: this.props.eDocContentFormIds,
        eDocContentForm: this.props.eDocContentForm,
        eContentisShowX:this.props.eContentisShowX ? this.props.eContentisShowX : '0'
    };

    render() {
        const {eDocContentForm,eContentisShowX} = this.state;
        let linkUrl = ``;
        if(eDocContentForm.length > 0) {
            linkUrl = `/spa/document/index.jsp?id=${eDocContentForm[0].id}&router=1#/main/document/detail?id=`;
        }
        let EDocContentFrom = <div></div>;
        if (this.props.eShareLevel == '2') {
            EDocContentFrom = (
                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@8okp1f`} label={getLabel(20885, '内容来源')} labelCol={{span: 6}} wrapperCol={{span: 16}}>
                    <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@oktr5o`}
                        type={9}
                        hasAdvanceSerach
                        isUseTest
                        icon="icon-toolbar-Organization-list"
                        iconBgcolor="#b32e37"
                        quickSearchName="docsubject"

                        searchsubject={false}
                        isSingle={true}
                        replaceDatas={eDocContentForm || []}
                        linkUrl={linkUrl}
                        onChange={(ids, names, datas) => this.setState({eDocContentFormIds: ids, eDocContentForm: datas})}
                    />
                </WeaFormItem>
            );
        }

        return (
            <div>
                <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@e630ls`} title={getLabel(81711, '基本信息')} needTigger={true} showGroup={true}>
                    <EType ecId={`${this && this.props && this.props.ecId || ''}_EType@cfkfaj`} ref="eType" value={this.props.eBaseName}/>
                    {this.props.eShareLevel == '2' ? <ETitle ecId={`${this && this.props && this.props.ecId || ''}_ETitle@t3kdx7`} ref="eTitle" eid={this.props.eid} value={this.props.eTitle} {...this.props}/> : ''}
                    {this.props.eShareLevel == '2' ? <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@izjh0i`} label={getLabel(518603, '是否横向滚动')} labelCol={{span: 6}} wrapperCol={{span: 16}}>
                            <div style={{width : '90px', display: 'inline-block', float: 'left'}}>
                                <WeaCheckbox ecId={`${this && this.props && this.props.ecId || ''}_WeaCheckbox@s9i4pf`}
                                    display="switch"
                                    value={eContentisShowX}
                                    onChange={v => {
                                        this.setState({eContentisShowX : v});
                                    }}
                                    // disabled={disabled}
                                />
                            </div>
                    </WeaFormItem>
                        :
                        ""
                    }
                    {EDocContentFrom}
                </WeaSearchGroup>
            </div>
        );
    }

    getSaveValues() {
        return {
            eContentTitle: this.refs['eTitle'] ? this.refs['eTitle'].getSaveValues() : this.props.eTitle,
            eContentisShowX: this.state.eContentisShowX,
            eContentDocContentForm: this.state.eDocContentFormIds,
        };
    }
}